import { Module, ValidationPipe } from '@nestjs/common';
import { APP_GUARD, APP_INTERCEPTOR, APP_PIPE } from '@nestjs/core';
import { AuthGuard } from './guard/auth.guard';
import { RoleGuard } from './guard/role.guard';
import { UserInfoGuard } from './guard/userInfo.guard';
import { ValidatePublic } from './guard/validatePublic';
import { LoggerInterceptor } from './interceptor/logger.interceptor';
import { TransformInterceptor } from './interceptor/transform.interceptor';
import { ApplyModule } from './modules/apply/apply.module';
import { ArticleModule } from './modules/article/article.module';
import { ArticleCategoryModule } from './modules/article-category/article-category.module';
import { AuthModule } from './modules/auth/auth.module';
import { BannerImageModule } from './modules/banner-image/banner-image.module';
import { CommentModule } from './modules/comment/comment.module';
import { PermActionModule } from './modules/perm-action/perm-action.module';
import { PermMenuModule } from './modules/perm-menu/perm-menu.module';
import { RoleModule } from './modules/role/role.module';
import { UploadModule } from './modules/upload/upload.module';
import { UserModule } from './modules/user/user.module';

@Module({
    imports: [
        RoleModule,
        UserModule,
        AuthModule,
        ArticleModule,
        ArticleCategoryModule,
        CommentModule,
        PermActionModule,
        PermMenuModule,
        BannerImageModule,
        ApplyModule,
        UploadModule,
    ],

    providers: [
        ValidatePublic,
        {
            provide: APP_GUARD,
            useClass: UserInfoGuard,
        },
        {
            provide: APP_GUARD,
            useClass: AuthGuard,
        },
        {
            provide: APP_GUARD,
            useClass: RoleGuard,
        },
        {
            provide: APP_INTERCEPTOR,
            useClass: LoggerInterceptor,
        },
        {
            provide: APP_INTERCEPTOR,
            useClass: TransformInterceptor,
        },
        {
            provide: APP_PIPE,
            useClass: ValidationPipe,
        },
    ],
})
export class ApiModule {}
